@extends('layouts.index')
<script type="text/javascript" src="{{asset('manger/plugins/layui2.0/layui.js')}}"></script>

<link href="{{asset('js/video/css/video-js.css')}}" rel="stylesheet">

<style type="text/css">
    .layui-upload-file{
        display: none;
    }
</style>
@section('title','上传作品')
    @section('content')
        <div class="main-container">
            <div class="account">
              @include('web.user.userInfo')
                        <div class="account-process__step account-process__step--active">
                            <div class="span2 hide-mobile"><br></div>
                            <div class="span12 span14-mobile account-process__step__content">
                                <form method="post" action="@if(isset($writing)) {{route('writing_update',['id'=>$writing->id])}} @else {{route('writing_store')}} @endif" novalidate="" id="id25" >
                                    {{csrf_field()}}
                                    <div class="account-block-content account-block-content--small-aside">
                                        <div class="">
                                            <aside class="span3 span12-tablet span10-mobile account-block-content__aside">
                                                @lang('web.basic_desc')
                                            </aside>

                                            <div class="span9 span100p-tablet span100p-mobile account-block-content__content">
                                                <div class="account-block-content__default">
                                                    <div class="account-block-content__default__section span3 span5-tablet span11-mobile">
                                                        <label class="custom-label relative">
                                                            <span class="custom-label__label">@lang('web.title')</span>
                                                            <input type="text" id="title" name="name" label="Project name" value="{{ old("name") ?? ($writing->name ?? '')}} " class="custom-input__input">
                                                        </label>
                                                    </div>
                                                </div>
                                                <div class="account-block-content__default">
                                                    <div class="account-block-content__default__section span5 span5-tablet span11-mobile">
                                                        <label class="custom-label relative">
                                                            <span class="custom-label__label">@lang('web.writing_desc')
                                                            	<span class="custom-label__label__btw"></span>
                                                            </span>
                                                            <textarea id="description" name="desc" label="Short description" rows="6" class="custom-input__textarea span8-tablet span100p-mobile">{{old('desc') ?? ($writing->desc ?? '') }}</textarea>
                                                        </label>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="cf"></div>
                                        </div>
                                    </div>
                                    @php
                                    $config=config('admin.writing');
                                    @endphp
                                    <div class="account-block-content account-block-content--small-aside">
                                        <div class="">
                                           <aside class="span3 span12-tablet span10-mobile account-block-content__aside">
                                                  @lang('web.writing')
                                               </aside>
                                           <div class="span9 span100p-tablet span100p-mobile account-block-content__content">
	                                               	<label class="custom-label">
	                                               		<span class="custom-label__label">
	                                               			<span class="custom-label__label__btw"></span>
	                                               			</span><span class="custom-label__label__btw"></span>
	                                               		</span>
	                                               	</label>
                                                    <div class="account-block-content__default">
                                                       <div class="account-block-content__default__section span6 span8-tablet span100p-mobile">
                                                           <div class="cf"></div>
                                                           <div class="custom-multicheckbox__container">
                                                        <select name="category_id" id="category_id" style="color: #8c8c8c">

                                                            @foreach($config as $k=>$v)
                                                                <option value="{{$k}}" @if(old("category_id") ?? ($writing->category_id ?? '')==$k) selected @endif >{{$v}}</option>
                                                            @endforeach
                                                        </select>
                                                           </div>
                                                       </div>
                                                    </div>
                                               </div>
                                           <aside class="span3 span12-tablet span10-mobile account-block-content__aside">
                                               @lang('web.theme')
                                            </aside>
                                            <div class="span9 span100p-tablet span100p-mobile account-block-content__content">
                                            	<label class="custom-label">
                                            		<span class="custom-label__label">
                                            			<span class="custom-label__label__btw">@lang('web.theme_desc')</span>
                                            			<span class="custom-label__label__btw"></span>
                                            			<span class="custom-label__label__btw"></span>
                                            			<span class="custom-label__label__btw"></span>
                                            		</span>
                                            	</label>
                                                <div class="account-block-content__default">
                                                    <div class="account-block-content__default__section span6 span8-tablet span100p-mobile">
                                                        <div class="cf"></div>
                                                        @if(isset($writing))
                                                            <div class="custom-multicheckbox__container" id="theme">
                                                                @if(count($theme)>0)
                                                                    @foreach($theme as $k=>$v)

                                                                        <label for="{{$k}}" class="span2 span4-tablet span7-mobile custom-checkbox custom-multicheckbox__item"><input type="checkbox" id="{{$k}}" name="theme_id" value="{{$v->id}}" @if($writing->theme_id==$v->id || old("theme_id")==$v->id) checked @endif class="custom-checkbox__input" ><div class="custom-checkbox__pseudo"></div>{{$v->name}}</label>

                                                                    @endforeach
                                                                @endif
                                                            </div>
                                                            @else
                                                        <div class="custom-multicheckbox__container" id="theme">

                                                        </div>
                                                            @endif
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="cf"></div>
                                        </div>
                                    </div>
                                    <div class="account-block-content account-block-content--small-aside">
                                        <div class="">
                                            <aside class="span3 span12-tablet span10-mobile account-block-content__aside">
                                            @lang('web.basic_eye')
                                            </aside>
                                            <div class="span9 span100p-tablet span100p-mobile account-block-content__content">
                                                <div class="account-block-content__default">
                                                    <div class="account-block-content__default__section span6 span100p-tablet span100p-mobile">
                                                        <label class="custom-label">
                                                            <span class="custom-label__label">@lang('web.thumb_image')
                                                                <span class="custom-label__label__btw">200·200 jpg / png</span>
                                                                <span class="custom-label__label__btw"></span>
                                                            </span>
                                                            <span class="custom-label__helptext">
                                                                <p>@lang('web.thumb_image_desc')<br></p>
                                                            </span>
                                                        </label>
                                                        <div class="form-dropzone pixel-pattern pixel-pattern--10">
                                                            <div class="form-dropzone__container">
                                                                @include('web.image.upload',['name'=>'thumb_img','value'=>old('thumb_img') ??
                                                               ($writing->thumb_img ?? '')])
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="account-block-content__default padding_top_30">
                                                    <div class="account-block-content__default__section span100p">
                                                        <label class="custom-label">
                                                            <span class="custom-label__label">@lang('web.master')
                                                                <span class="custom-label__label__btw">877·560 jpg / png</span>
                                                                <span class="custom-label__label__btw"></span>
                                                            </span>
                                                            <span class="custom-label__helptext"><p>@lang('web.silde')。<br></p></span>
                                                        </label>
                                                        <div class="form-dropzone pixel-pattern pixel-pattern--10">
                                                            <div class="form-dropzone__container">

                                                                @if(isset($writing))
                                                                    @include('web.image.upload',['name'=>'master1','value'=> old('master1') ?? $writing->master[0] ])
                                                                    @include('web.image.upload',['name'=>'master2','value'=>old('master2') ?? $writing->master[1] ])
                                                                    @include('web.image.upload',['name'=>'master3','value'=>old('master3') ??
                                                                    $writing->master[2] ])
                                                                    @else
                                                                @include('web.image.upload',['name'=>'master1','value'=>old('master1')])
                                                                @include('web.image.upload',['name'=>'master2','value'=>old('master2')])
                                                                @include('web.image.upload',['name'=>'master3','value'=>old('master3')])
                                                                    @endif
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="account-block-content__default padding_top_30">
                                                    <div class="account-block-content__default__section span3 span5-tablet span11-mobile">
                                                        <label class="custom-label relative"><span class="custom-label__label">@lang('web.video')
                                                                <span class="custom-label__label__btw">@lang('web.optional')
                                                                    <span class="custom-label__label__btw"></span>
                                                                </span>
                                                                <input type="text" id="showreelUrl" name="video_url" value="{{old("video_url") ?? ($writing->video_url ?? '')}}" label="PROJECT DEMO REEL/VIDEO" placeholder="@lang('web.your_video')" class="custom-input__input" style="margin-top: 30px;">
                                                        </label>
                                                    </div>
                                                </div>

                                                <div class="account-block-content__default">
                                                    <div class="account-block-content__default__section span3 span5-tablet span11-mobile">
                                                        <label class="custom-label relative">
                                                            <span class="custom-label__label">@lang('web.video')
                                                                <span class="custom-label__label__btw">@lang('web.optional')</span>
                                                                <span class="custom-label__label__btw"></span>
                                                            </span>
                                                        </label>
@if(isset($writing)&& $writing->video!='')

                                       @include('web.image.fileupload',['name'=>'video','value'=>old("video") ?? ($writing->video ?? '')])
    @else
                                        @include('web.image.fileupload',['name'=>'video','value'=>old("video")])
    @endif
                                         </div>
                                              </div>
                                                <div class="cf"></div>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="account-block-content account-block-content--small-aside">
                                    </div>
                                    <div class="account-block-content pixel-pattern pixel-pattern--01 account-block-content--small-aside">
                                        <div class="">
                                            <aside class="span3 span12-tablet span10-mobile account-block-content__aside account-block-content__aside--no-content"></aside>
                                            <div class="span9 span100p-tablet span100p-mobile account-block-content__content">
                                                <div class="span9 span100p-tablet span100p-mobile">
                                                    <div class="account-process__button-area"><button type="submit" class="button--dark">@lang('web.submit')</button></div>
                                                </div>
                                            </div>
                                            <div class="cf"></div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="cf"></div>
                        </div>
            </div>
        </div>


        <script>
        $("#category_id").change(function(){
            get_theme($("#category_id").val());
        });
       function get_theme(category_id){
           $.get("{{route('get_theme')}}",{category_id:category_id},function (data) {
               $("#theme").html(data);
           })
       }
       @if(isset($writing))
        @else
        get_theme(0);
       @endif

        </script>

        @endsection